package com.example.room

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.example.common.User

@Database(entities = [User::class], version = 1, exportSchema = false)
abstract class AppDabase : RoomDatabase() {
    abstract fun UserDAO(): UserDAO
    companion object{
        private var instance : AppDabase? = null
        fun getInstance(context:Context): AppDabase {
            if(instance == null){
                synchronized(AppDabase::class){
                    instance = Room.databaseBuilder(context,
                    AppDabase::class.java,"user.db")
                        .build()
                }
            }
            return instance!!
        }
    }
}